﻿using System;
using System.IO;
namespace Common
{
   public class FileIOHelper
    {
       /// <summary>
       /// 以“config/AAA.XML”这样的路径创建文件夹，需要删除生成的config的所有子目录如AAA.xml目录，只保留config
       /// </summary>
       /// <param name="path"></param>
       public static void CreateFolderFromPaths(string path)
       {
            DirectoryInfo di = new DirectoryInfo(path);
            di.Parent.Attributes = FileAttributes.Normal & FileAttributes.Directory;
            if (!Directory.Exists(path))
            { 
                if(!di.Exists)
                  di.Create(); 
            }
           
            
       }


       /// <summary>
       /// 在路径处创建一个新的空文件
       /// </summary>
       /// <param name="path"></param>
       public static void CreateEmptyFile(string path)
       {
           FileInfo fi = new FileInfo(path);
           if (!File.Exists(path)) 
           { 
               if(!fi.Exists)
                  fi.Create(); 
           }
       }
    }
}
